<?php
// +----------------------------------------------------------------------
// | CoreThink [ Simple Efficient Excellent ]
// +----------------------------------------------------------------------
// | Copyright (c) 2014 http://www.corethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: jry <598821125@qq.com> <http://www.corethink.cn>
// +----------------------------------------------------------------------
namespace Home\Controller;
use Think\Controller;
/**
 * 前台默认控制器
 * @author jry <598821125@qq.com>
 */
class IndexController extends HomeController{
    /**
     * 默认方法
     * @author jry <598821125@qq.com>
     */
    public function index(){
        Cookie('__forward__', $_SERVER['REQUEST_URI']);
        $notice=M("category")->where(array('title'=>'公告'))->find();
        $msg=M("document")->join('ct_document_article as da ON da.id=ct_document.id')->where("ct_document.cid={$notice['id']} and ct_document.doc_type=3 and ct_document.status=1")->field('ct_document.id,ct_document.ctime,da.title')->order('ct_document.id desc')->limit(7)->select();
        $this->assign("gg",$msg); 
        $xwzx=M("document")->join('ct_document_article as da ON da.id=ct_document.id')->where("ct_document.cid=31 and ct_document.doc_type=3 and ct_document.status=1")->field('ct_document.id,ct_document.ctime,da.title,da.cover,da.abstract')->order('ct_document.id desc')->limit(7)->select();
        $this->assign("xwzx",$xwzx);
        $jsxx=M("document")->join('ct_document_article as da ON da.id=ct_document.id')->where("ct_document.cid=34 and ct_document.doc_type=3 and ct_document.status=1")->field('ct_document.id,ct_document.ctime,da.title,da.cover,da.abstract')->order('ct_document.id desc')->limit(3)->select();
        $this->assign("jsxx",$jsxx);
        $jrpl=M("document")->join('ct_document_article as da ON da.id=ct_document.id')->where("ct_document.cid=32 and ct_document.doc_type=3 and ct_document.status=1")->field('ct_document.id,ct_document.ctime,da.title,da.cover,da.abstract')->order('ct_document.id desc')->limit(3)->select();
        $this->assign("jrpl",$jrpl);
        $cjzx=M("document")->join('ct_document_article as da ON da.id=ct_document.id')->where("ct_document.cid=33 and ct_document.doc_type=3 and ct_document.status=1")->field('ct_document.id,ct_document.ctime,da.title,da.cover,da.abstract')->order('ct_document.id desc')->limit(7)->select();
        $this->assign("cjzx",$cjzx);
        $adsinfo=M('Ads')->where(array('status'=>1))->select();
        $this->assign('adsinfo',$adsinfo);
        $this->assign('partner',M('Partner')->select());//合作伙伴
        $this->assign('meta_title', "首页");
        $this->display('');
    }
    function getCatInfo()
    {
    	$cat=I("cat",1);
    	$catList=M("category")->where(array('pid'=>0,'doc_type'=>3,'status'=>1))->select();
    	$data='';
    	foreach ($catList as $v)
    	{
    		$data.='<option value="'.$v['id'].'"';
    		if($cat == $v['id'])
    		{
    			$data.='selected';
    		}
    		$data.='>';
    		$data.=$v['title'].'</option>';
    	}
    	$infolist=M("document")->join('ct_document_article as da ON da.id=ct_document.id')->where("ct_document.cid=$cat and ct_document.doc_type=3 and ct_document.status=1")->field('ct_document.id,ct_document.ctime,da.title,da.cover,da.abstract')->order('ct_document.id desc')->limit(10)->select();
    	$list='';
    	foreach ($infolist as $v)
    	{
    		$time=date('Y-m-d H:i',$v['ctime']);
    		$list.='<li>';
    		$list.='<span><a href="./index.php?s=/Home/Document/getdocContent/id/'.$v['id'].'" >'.$v['title'].'</a></span>';
    		$list.='<span class="am-my-list-date">'.$time.'</span>';
    		$list.='</li>';	
    		$time='';
    	}
    	$return['list']=$list;
    	$return['cat']=$data;
    	$this->ajaxReturn($return);
     }
    function jydt()
    {
        $currency=currency();//获取全部币种信息
        //24H涨跌--7D涨跌--24H成交量--24H成交额
        foreach ($currency as $k=>$v)
        {
            $cur_zui[$v['id']]=getCurrencyMessageById($v['id']);
        }
        //dump($cur_zui);
        $this->assign('cur_zui',$cur_zui);
    	$this->display('Index/jydt');
    }
    function kaihu()
    {
    	$this->display('Index/kaihu');
    }
    function buyAndout()
    {
    	$this->display('Index/buyAndout');
    }
}
